﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for MyAsyncHandler
/// </summary>
public class MyAsyncHandler : System.Web.IHttpAsyncHandler
{

    #region IHttpAsyncHandler Members

    byte[] buffer = new byte[4096];

    public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
    {
        string path = context.Server.MapPath("~/web.config");
        System.IO.FileStream fs = new System.IO.FileStream(  path, System.IO.FileMode.Open);
        return fs.BeginRead(buffer, 0, 4096, this.EndProcessRequest, fs);
    }

    public void EndProcessRequest(IAsyncResult result)
    {
        System.IO.FileStream fs = result.AsyncState as System.IO.FileStream;
        int length = fs.EndRead(result);
    }

    #endregion

    #region IHttpHandler Members

    public bool IsReusable
    {
        get { return false; }
    }

    public void ProcessRequest(HttpContext context)
    {
        throw new NotImplementedException();
    }

    #endregion
}